package com.example.tests;

import java.util.logging.Logger;

import org.testng.annotations.Test;

import com.example.fw.GroupObject;
import com.example.fw.Groups;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

public class GroupCreationTests extends TestBase {
	
	private Logger log = Logger.getLogger("GroupCreationTests");
	
	@Test(dataProvider = "groupsFromFile", dataProviderClass =  GroupDataGenerator.class)
	public void testValidGroupCanBeCreated(GroupObject validGroup) throws Exception {
		log.info("testValidGroupCanBeCreated start");
		Groups oldList = app.getGroupHelper().getGroups();
		log.info("oldList = " + oldList);
		app.getGroupHelper().createGroup(validGroup);
		log.info("validGroup = " + validGroup);
		Groups newList = app.getGroupHelper().getGroups();
		log.info("newList = " + newList);
		assertThat(newList, equalTo(oldList.withAdded(validGroup)));
		log.info("testValidGroupCanBeCreated end");
	}
	
	//@Test
	public void testEmptyGroupCanBeCreated() throws Exception {
		GroupObject emptyGroup = new GroupObject().setName("").setHeader("").setFooter("");
		Groups oldList = app.getGroupHelper().getGroups();
		app.getGroupHelper().createGroup(emptyGroup);
		Groups newList = app.getGroupHelper().getGroups();
		assertThat(newList, equalTo(oldList.withAdded(emptyGroup)));		
	}
}
